package scantask.containers;

import java.util.Vector;

import scantask.containers.exceptions.IllegalPasswordException;
import scantask.containers.exceptions.IllegalUserNameException;
import scantask.containers.exceptions.UnInitializeObjectException;

public class User {
	
	private String _userName;
	private String _password;
	private String _fullName;
	private Coordinate _defaultCoordinate;
	private Vector<Area> _areas;
	
	public User(String userName, String password, String fullName, Coordinate coordinate) throws IllegalUserNameException, IllegalPasswordException {
		if (userName.compareTo("") == 0) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new User illegale userName");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new User illegale userName");
			throw new IllegalUserNameException();
		}
		if (password.compareTo("") == 0) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new User illegale password");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new User illegale password");
			throw new IllegalPasswordException();
		}
		this._userName = userName;
		this._password = password;
		this._fullName = fullName;
		this._defaultCoordinate = coordinate;
	}
	
	public User(String userName, String password, String fullName, Coordinate coordinate, Vector<Area> areas) throws IllegalUserNameException, IllegalPasswordException {
		if (userName.compareTo("") == 0) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new User illegale userName");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new User illegale userName");
			throw new IllegalUserNameException();
		}
		if (password.compareTo("") == 0) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new User illegale password");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed construct new User illegale password");
			throw new IllegalPasswordException();
		}
		this._userName = userName;
		this._password = password;
		this._fullName = fullName;
		this._defaultCoordinate = coordinate;
		this._areas = areas;
	}
	
	public String getUserName() {
		return this._userName;
	}
	
	public String getPassword() {
		return this._password;
	}
	
	public String getFullName() {
		return this._fullName;
	}
	
	public Coordinate getDefaultCoordinate() throws UnInitializeObjectException {
		if (this._defaultCoordinate == null) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("try to get null Coordinate");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("try to get null Coordinate");
			throw new UnInitializeObjectException();
		}
		
		return this._defaultCoordinate;
	}
	
	public Vector<Area> getUserAreas() throws UnInitializeObjectException {
		if (this._areas == null) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("try to get null Areas");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("try to get null Areas");
			throw new UnInitializeObjectException();
		}
		return this._areas;
	}
	
	public void setUserName(String userName) throws IllegalUserNameException {
		if (userName.compareTo("") == 0) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed set userName, illegale userName");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed set userName, illegale userName");
			throw new IllegalUserNameException();
		}
		
		this._userName = userName;
	}
	
	public void setPassword(String password) throws IllegalPasswordException {
		if (password.compareTo("") == 0) {
			scantask.server.utilities.logging.SingletonLogger.getLogger().warning("Failed set password, illegale password");
			scantask.client.utilities.logging.SingletonLogger.getLogger().warning("Failed set password, illegale password");
			throw new IllegalPasswordException();
		}
		
		this._password = password;
	}
	
	public void setFullName(String fullName) {
		this._fullName = fullName;
	}
	
	public void setDefaultCoordinate(Coordinate coordinate) {
		this._defaultCoordinate = coordinate;
	}
	
	public void setUserAreas(Vector<Area> areas) {
		this._areas = areas;
	}

}
